/*
* Copyright (C) 2024-2025 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include "widgets/defendertable.h"
#include "schedulescanitem.h"
#include "widgets/safetyprotectionitem.h"
#include "widgets/menuitem.h"
#include "widgets/multicombox.h"


//#include <DBlurEffectWidget>
//#include <DSuggestButton>
#include <QTimeEdit>

#include <QRadioButton>
#include <QDialog>
#include <QButtonGroup>
#include <QObject>

#define PB_CANCLE_WIDTH 170 // 取消按钮宽度
#define PB_CANCLE_HEIGHT 36 // 取消按钮高度
#define LINE_HEIGHT 28 // 分割线高度

class HFrame1;
class SettingsInvokerInterface;
class DBusInvokerInterface;

// 定时扫描时间类型
enum ScheduleScanTimeType {
    Everyday = 0, // 每天
    Everyweek, // 每周
    Everymonth, // 每月
    CustomizeType //自定义
};

using namespace def::widgets;

class DEVCOMMONSHARED_EXPORT ScheduleScanDialog : public QFrame
{
    Q_OBJECT
public:
    explicit ScheduleScanDialog(QWidget *parent = nullptr);

private:
    // 初始化界面
    void initUI();
    // 初始化数据
    void initData();

    // 根据开关状态置灰/置亮空间
    void setWidgetStatus(bool bStatus);
    // 定时时间gsetting设置
    void setTimeGsetting();

    // 添加安全日志
    QString getLogStr();
    // 处理每周 同名及转换字符串
    QString selectWeeksHandle();
    // 处理每月 同名及转换字符串
    QString selectMonthsHandle();

private Q_SLOTS:
    // 表格内下拉框选项改变
    void onAppOneChanged(int index);

    // 定时扫描总开关状态改变槽
    void acceptTimerScanSwitchStatusChange();

    // 定时扫描确定按钮设置槽
    void acceptConfirmButtonClicked();

    // 根据界面上的按钮状态确定设置结果
    void setSettingResult();

private:
    DBusInvokerInterface *m_monitorNetFlowInter; // 系统服务
//    DBlurEffectWidget *m_blurEffect; // 透明背景
    ScheduleScanItem *m_setupItemNew; // 定时扫描设置选项
    QButtonGroup *m_pTypeButtonGrop; // 扫描类型按钮组
    QRadioButton *m_quickButton; // 快速扫描按钮
    QRadioButton *m_fullButton; // 全盘扫描按钮
    QButtonGroup *m_pFoundButtonGrop; // 发现病毒处理方式按钮组
    QRadioButton *m_askButton; // 询问按钮
    QRadioButton *m_autoButton; // 自动处理按钮
    QComboBox *m_timeSpanCombobox; // 时间跨度下拉框
    MultiComBox *m_dayOfMonthMultiComboBox; // 月份日期选择下拉框
    MultiComBox *m_dayOfWeekMultiComboBox; // 星期日期选择下拉框
    QDateEdit *m_dateEdit; // 日期编辑器
    QTimeEdit *m_timeEdit; // 时间编辑器
    HFrame1 *m_contentWidget; // 内容装置
    QPushButton *m_pCancelBtn; // 取消按钮
    QFrame *m_line; // 分割线
    QPushButton *m_pConfirmBtn; // 确认按钮

    QTime m_defaultTime;
    SettingsInvokerInterface *m_gsetting; //安全中心gsetting配置
    bool m_timerScanSwitch;
    bool m_timerScanType;
    QString m_sScanTime;
    bool m_timerScanHandle;
};
